//订单管理
var url = require('url');
var template = require('templateConfig');
var main = require('main');
var module= require('module');
//模板配置
var tplArr = [];
var ManagerTpl =require('raw!../template/manager.txt'); 
tplArr['manager'] = template.compile(ManagerTpl.replace(/^\s*|\s*$/g, "")); 

 
var goodsInfo = {
    "id": 1,
    "title":"大家乐文胸一片式无痕内衣厚B杯深V聚拢商场同款内衣1",
    "attr": [],
    "num":"1002837828372",
    "spec":"大红,B杯,34/75",
    //"quantity":"1",
    //"inStock":"258",
    //"colour":"红色、粉色、嫩肤",
    //"cup":"A杯、B杯、C杯",
    //"size":"32/70、40/75",
    //"price":"98",
};
var data2 = [
            	{
            		"id":"",
            		"num":"12321231",
            		"goodsInfo": module.ordersGoodsInfo([goodsInfo]),
            		"editUrl":"#",
            		"price":"99.10",
            	},{
            		"id":"",
            		"num":"12321232",
            		"goodsInfo": module.ordersGoodsInfo([goodsInfo]),
            		"editUrl":"#",
            		"price":"99.20",
            	},{
            		"id":"",
            		"num":"12321233",
            		"goodsInfo": module.ordersGoodsInfo([goodsInfo]),
            		"editUrl":"#",
            		"price":"99.30",
            	}
            ];

function Index(){
    _this = this;
    this.main = function(){
        main.event(this,'tap','om-click'); 
        main.event(this,'change','om-change'); 
        this.init();
    }
    //初始化内容
    this.createHtml = function(){ 
    	var html = '';
    	html = module.getModule({"placeholder":"搜索商品名称／商品编号／订单号"},'search')+
               module.getModule({"fun":'om-change="selectFun"',"list":["全部订单","未支付"],"selected":"未支付"},'baseSelect')+
               _this.orderManagerList();
        $('.ui-container').html(html); 
    }
    //下拉筛选
    this.selectFun = function(ths){
    	alert(ths.val());
    }
    //订单管理列表
    this.orderManagerList = function(){
    	var data= {
            "tType": "orderManagerList",
            "list": data2
        }
        return tplArr['manager'](data);
    }
    this.getFooter =function() {
        var data= {}; 
        data = {
            tType: "footer",
            active: "0",
            dataList: [{
                link: url.Index,
                icon: "ui-icon-home",
                name: "首页"
            },{
                link: url.shopCar,
                icon: "ui-icon-cart",
                name: "购物车",
            },{
                link: url.Center,
                icon: "ui-icon-personal",
                name: "个人中心"
            }]
        }
        $(".wrap").append(module.getModule(data, "footer")) 
         
    }
    this.init= function(){
    	this.createHtml(); 
        this.getFooter();  
        this.baseUrl= url.baseImageUrl; 	
    }
    return this.main();
};

var index = new Index();